const DEFAULT_STATE = 0;
const ADD = 'ADD';
const addPayload = function (payload) {
    return {
        type: ADD,
        payload
    };
};
const logger = store => next => action => {
    console.group(action.type);
    console.info('dispatching', action);
    let result = next(action);
    console.log('next state', store.getState());
    console.groupEnd(action.type);
    return result;
};
const count = (state = DEFAULT_STATE, {type, payload}) => {
    console.log('reducer', type, payload);
    switch (type) {
        case ADD:
            return state + payload;
        default:
            return state;
    }
};

const {createStore, combineReducers, applyMiddleware} = Redux;

const store = createStore(combineReducers({
    count
}), applyMiddleware(logger));

const unsubscribe = store.subscribe(() => console.log('subscribe'));

console.log('store', store);
console.log('store 的初始状态', store.getState());

store.dispatch(addPayload(3));
console.log('addPayload(3) 后', store.getState());

unsubscribe();
console.log('取消关注');

store.dispatch(addPayload(2));
console.log('再次 addPayload(5) 后', store.getState());